import { defineAsyncComponent } from 'vue';
const adminComps = import.meta.glob('@/admin/components/**/*.vue');

export default function install(app) {
  Object.entries(adminComps).forEach(([key, value]) => {
    const paths = key.replace('/src/admin/', '').split('/');
    let name = 'ac-' + paths[1];
    name = name.replace(/[A-Z]/g, function(str) {
      return '-' + str.toLowerCase();
    });
    app.component(name, defineAsyncComponent(value));
  });
}